#pragma once

#include "stats.hpp"
#include <map>
#include <string>
#include <queue>
#include <vector>
#include <cstdint>
#include <chrono>

namespace perf_monitor {
    typedef enum EVENT_ID {
        EVENT_ID_CAPTURECHANGED = 0,
        EVENT_ID_CHAR = 1,
        EVENT_ID_FOCUS = 2,
        EVENT_ID_CLOSE = 3,
        EVENT_ID_DESTROY = 4,
        EVENT_ID_IDLE = 5,
        EVENT_ID_POLL = 6,
        EVENT_ID_INITIALIZE = 7,
        EVENT_ID_KEYDOWN = 8,
        EVENT_ID_KEYUP = 9,
        EVENT_ID_KEYDOWN_REPEATING = 10,
        EVENT_ID_MOUSEDOWN = 11,
        EVENT_ID_MOUSEMOVE = 12,
        EVENT_ID_MOUSEMOVE_RELATIVE = 13,
        EVENT_ID_MOUSEUP = 14,
        EVENT_ID_MOUSEMODE_CHANGED = 15,
        EVENT_ID_MOUSEWHEEL = 16,
        EVENT_ID_PAINT = 17,
        EVENT_ID_NET_DATA = 18,
        EVENT_ID_NET_CONNECT = 19,
        EVENT_ID_NET_DISCONNECT = 20,
        EVENT_ID_NET_CANTCONNECT = 21,
        EVENT_ID_NET_DESTROY = 22,
        EVENT_ID_CONSOLE_INPUT = 23,
        EVENT_ID_ENGINENET = 24,
        EVENT_ID_BATTLENET = 25,
        EVENT_ID_WOW_Q_IDLE = 26,
        EVENT_ID_IME = 27,
        EVENT_ID_SIZE = 28,
        EVENTIDS = 29
    } EVENT_ID;

    enum Events : std::uint32_t {
        UNIT_PET_01 = 0u,
        UNIT_PET_02 = 2u,
        UNIT_HEALTH = 16u,
        UNIT_MANA_01 = 17u,
        UNIT_RAGE = 18u,
        UNIT_FOCUS = 19u,
        UNIT_ENERGY = 20u,
        UNIT_HAPPINESS = 21u,
        UNIT_MAXHEALTH = 22u,
        UNIT_MAXMANA = 23u,
        UNIT_MAXRAGE = 24u,
        UNIT_MAXFOCUS = 25u,
        UNIT_MAXENERGY = 26u,
        UNIT_MAXHAPPINESS = 27u,
        UNIT_LEVEL = 28u,
        UNIT_FACTION = 29u,
        UNIT_DISPLAYPOWER = 30u,
        UNIT_FLAGS = 40u,
        UNIT_AURA_01 = 41u,
        UNIT_AURA_02 = 107u,
        UNIT_ATTACK_SPEED_01 = 120u,
        UNIT_ATTACK_SPEED_02 = 121u,
        UNIT_RANGEDDAMAGE_01 = 122u,
        UNIT_DAMAGE_01 = 128u,
        UNIT_DAMAGE_02 = 129u,
        UNIT_DAMAGE_03 = 130u,
        UNIT_DAMAGE_04 = 131u,
        UNIT_LOYALTY = 132u,
        UNIT_PET_EXPERIENCE_01 = 135u,
        UNIT_PET_EXPERIENCE_02 = 136u,
        UNIT_DYNAMIC_FLAGS = 137u,
        UNIT_PET_TRAINING_POINTS = 143u,
        UNIT_STATS_01 = 144u,
        UNIT_STATS_02 = 145u,
        UNIT_STATS_03 = 146u,
        UNIT_STATS_04 = 147u,
        UNIT_STATS_05 = 148u,
        UNIT_RESISTANCES_01 = 149u,
        UNIT_RESISTANCES_02 = 150u,
        UNIT_RESISTANCES_03 = 151u,
        UNIT_RESISTANCES_04 = 152u,
        UNIT_RESISTANCES_05 = 153u,
        UNIT_RESISTANCES_06 = 154u,
        UNIT_RESISTANCES_07 = 155u,
        UNIT_ATTACK_POWER_01 = 159u,
        UNIT_ATTACK_POWER_02 = 160u,
        UNIT_ATTACK_POWER_03 = 161u,
        UNIT_RANGED_ATTACK_POWER_01 = 162u,
        UNIT_RANGED_ATTACK_POWER_02 = 163u,
        UNIT_RANGED_ATTACK_POWER_03 = 164u,
        UNIT_RANGEDDAMAGE_02 = 165u,
        UNIT_RANGEDDAMAGE_03 = 166u,

        UNIT_MANA1 = 167,
        UNIT_MANA2 = 174,

        UNIT_COMBAT = 182,

        UNIT_NAME_UPDATE = 183,
        UNIT_PORTRAIT_UPDATE = 184,
        UNIT_MODEL_CHANGED = 185,
        UNIT_INVENTORY_CHANGED = 186,
        UNIT_CLASSIFICATION_CHANGED = 187,
        ITEM_LOCK_CHANGED = 188,
        PLAYER_XP_UPDATE = 189,
        PLAYER_REGEN_DISABLED = 190,
        PLAYER_REGEN_ENABLED = 191,
        PLAYER_AURAS_CHANGED = 192,
        PLAYER_ENTER_COMBAT = 193,
        PLAYER_LEAVE_COMBAT = 194,
        PLAYER_TARGET_CHANGED = 195,
        PLAYER_CONTROL_LOST = 196,
        PLAYER_CONTROL_GAINED = 197,
        PLAYER_FARSIGHT_FOCUS_CHANGED = 198,
        PLAYER_LEVEL_UP = 199,
        PLAYER_MONEY = 200,
        PLAYER_DAMAGE_DONE_MODS = 201,
        PLAYER_COMBO_POINTS = 202,
        ZONE_CHANGED = 203,
        ZONE_CHANGED_INDOORS = 204,
        ZONE_CHANGED_NEW_AREA = 205,
        MINIMAP_ZONE_CHANGED = 206,
        MINIMAP_UPDATE_ZOOM = 207,
        SCREENSHOT_SUCCEEDED = 208,
        SCREENSHOT_FAILED = 209,
        ACTIONBAR_SHOWGRID = 210,
        ACTIONBAR_HIDEGRID = 211,
        ACTIONBAR_PAGE_CHANGED = 212,
        ACTIONBAR_SLOT_CHANGED = 213,
        ACTIONBAR_UPDATE_STATE = 214,
        ACTIONBAR_UPDATE_USABLE = 215,
        ACTIONBAR_UPDATE_COOLDOWN = 216,
        UPDATE_BONUS_ACTIONBAR = 217,
        PARTY_MEMBERS_CHANGED = 218,
        PARTY_LEADER_CHANGED = 219,
        PARTY_MEMBER_ENABLE = 220,
        PARTY_MEMBER_DISABLE = 221,
        PARTY_LOOT_METHOD_CHANGED = 222,
        SYSMSG = 223,
        UI_ERROR_MESSAGE = 224,
        UI_INFO_MESSAGE = 225,
        UPDATE_CHAT_COLOR = 226,
        CHAT_MSG_ADDON = 227,
        CHAT_MSG_SAY = 228,
        CHAT_MSG_PARTY = 229,
        CHAT_MSG_RAID = 230,
        CHAT_MSG_GUILD = 231,
        CHAT_MSG_OFFICER = 232,
        CHAT_MSG_YELL = 233,
        CHAT_MSG_WHISPER = 234,
        CHAT_MSG_WHISPER_INFORM = 235,
        CHAT_MSG_EMOTE = 236,
        CHAT_MSG_TEXT_EMOTE = 237,
        CHAT_MSG_SYSTEM = 238,
        CHAT_MSG_MONSTER_SAY = 239,
        CHAT_MSG_MONSTER_YELL = 240,
        CHAT_MSG_MONSTER_WHISPER = 241,
        CHAT_MSG_MONSTER_EMOTE = 242,
        CHAT_MSG_CHANNEL = 243,
        CHAT_MSG_CHANNEL_JOIN = 244,
        CHAT_MSG_CHANNEL_LEAVE = 245,
        CHAT_MSG_CHANNEL_LIST = 246,
        CHAT_MSG_CHANNEL_NOTICE = 247,
        CHAT_MSG_CHANNEL_NOTICE_USER = 248,
        CHAT_MSG_AFK = 249,
        CHAT_MSG_DND = 250,
        CHAT_MSG_COMBAT_LOG = 251,
        CHAT_MSG_IGNORED = 252,
        CHAT_MSG_SKILL = 253,
        CHAT_MSG_LOOT = 254,
        CHAT_MSG_MONEY = 255,
        CHAT_MSG_RAID_LEADER = 256,
        CHAT_MSG_RAID_WARNING = 257,
        LANGUAGE_LIST_CHANGED = 258,
        TIME_PLAYED_MSG = 259,
        SPELLS_CHANGED = 260,
        CURRENT_SPELL_CAST_CHANGED = 261,
        SPELL_UPDATE_COOLDOWN = 262,
        SPELL_UPDATE_USABLE = 263,
        CHARACTER_POINTS_CHANGED = 264,
        SKILL_LINES_CHANGED = 265,
        ITEM_PUSH = 266,
        LOOT_OPENED = 267,
        LOOT_SLOT_CLEARED = 268,
        LOOT_CLOSED = 269,
        PLAYER_LOGIN = 270,
        PLAYER_LOGOUT = 271,
        PLAYER_ENTERING_WORLD = 272,
        PLAYER_LEAVING_WORLD = 273,
        PLAYER_ALIVE = 274,
        PLAYER_DEAD = 275,
        PLAYER_CAMPING = 276,
        PLAYER_QUITING = 277,
        LOGOUT_CANCEL = 278,
        RESURRECT_REQUEST = 279,
        PARTY_INVITE_REQUEST = 280,
        PARTY_INVITE_CANCEL = 281,
        GUILD_INVITE_REQUEST = 282,
        GUILD_INVITE_CANCEL = 283,
        GUILD_MOTD = 284,
        TRADE_REQUEST = 285,
        TRADE_REQUEST_CANCEL = 286,
        LOOT_BIND_CONFIRM = 287,
        EQUIP_BIND_CONFIRM = 288,
        AUTOEQUIP_BIND_CONFIRM = 289,
        USE_BIND_CONFIRM = 290,
        DELETE_ITEM_CONFIRM = 291,
        CURSOR_UPDATE = 292,
        ITEM_TEXT_BEGIN = 293,
        ITEM_TEXT_TRANSLATION = 294,
        ITEM_TEXT_READY = 295,
        ITEM_TEXT_CLOSED = 296,
        GOSSIP_SHOW = 297,
        GOSSIP_ENTER_CODE = 298,
        GOSSIP_CLOSED = 299,
        QUEST_GREETING = 300,
        QUEST_DETAIL = 301,
        QUEST_PROGRESS = 302,
        QUEST_COMPLETE = 303,
        QUEST_FINISHED = 304,
        QUEST_ITEM_UPDATE = 305,
        TAXIMAP_OPENED = 306,
        TAXIMAP_CLOSED = 307,
        QUEST_LOG_UPDATE = 308,
        TRAINER_SHOW = 309,
        TRAINER_UPDATE = 310,
        TRAINER_CLOSED = 311,
        CVAR_UPDATE = 312,
        TRADE_SKILL_SHOW = 313,
        TRADE_SKILL_UPDATE = 314,
        TRADE_SKILL_CLOSE = 315,
        MERCHANT_SHOW = 316,
        MERCHANT_UPDATE = 317,
        MERCHANT_CLOSED = 318,
        TRADE_SHOW = 319,
        TRADE_CLOSED = 320,
        TRADE_UPDATE = 321,
        TRADE_ACCEPT_UPDATE = 322,
        TRADE_TARGET_ITEM_CHANGED = 323,
        TRADE_PLAYER_ITEM_CHANGED = 324,
        TRADE_MONEY_CHANGED = 325,
        PLAYER_TRADE_MONEY = 326,
        BAG_OPEN = 327,
        BAG_UPDATE = 328,
        BAG_CLOSED = 329,
        BAG_UPDATE_COOLDOWN = 330,
        LOCALPLAYER_PET_RENAMED = 331,
        UNIT_ATTACK = 332,
        UNIT_DEFENSE = 333,
        PET_ATTACK_START = 334,
        PET_ATTACK_STOP = 335,
        UPDATE_MOUSEOVER_UNIT = 336,
        SPELLCAST_START = 337,
        SPELLCAST_STOP = 338,
        SPELLCAST_FAILED = 339,
        SPELLCAST_INTERRUPTED = 340,
        SPELLCAST_DELAYED = 341,
        SPELLCAST_CHANNEL_START = 342,
        SPELLCAST_CHANNEL_UPDATE = 343,
        SPELLCAST_CHANNEL_STOP = 344,
        PLAYER_GUILD_UPDATE = 345,
        QUEST_ACCEPT_CONFIRM = 346,
        PLAYERBANKSLOTS_CHANGED = 347,
        BANKFRAME_OPENED = 348,
        BANKFRAME_CLOSED = 349,
        PLAYERBANKBAGSLOTS_CHANGED = 350,
        FRIENDLIST_UPDATE = 351,
        IGNORELIST_UPDATE = 352,
        PET_BAR_UPDATE = 353,
        PET_BAR_UPDATE_COOLDOWN = 354,
        PET_BAR_SHOWGRID = 355,
        PET_BAR_HIDEGRID = 356,
        MINIMAP_PING = 357,
        CHAT_MSG_COMBAT_MISC_INFO = 358,
        CRAFT_SHOW = 359,
        CRAFT_UPDATE = 360,
        CRAFT_CLOSE = 361,
        MIRROR_TIMER_START = 362,
        MIRROR_TIMER_PAUSE = 363,
        MIRROR_TIMER_STOP = 364,
        WORLD_MAP_UPDATE = 365,
        WORLD_MAP_NAME_UPDATE = 366,
        AUTOFOLLOW_BEGIN = 367,
        AUTOFOLLOW_END = 368,
        SPELL_QUEUE_EVENT = 369,
        CINEMATIC_START = 370,
        CINEMATIC_STOP = 371,
        UPDATE_FACTION = 372,
        CLOSE_WORLD_MAP = 373,
        OPEN_TABARD_FRAME = 374,
        CLOSE_TABARD_FRAME = 375,
        TABARD_CANSAVE_CHANGED = 376,
        SHOW_COMPARE_TOOLTIP = 377,
        GUILD_REGISTRAR_SHOW = 378,
        GUILD_REGISTRAR_CLOSED = 379,
        DUEL_REQUESTED = 380,
        DUEL_OUTOFBOUNDS = 381,
        DUEL_INBOUNDS = 382,
        DUEL_FINISHED = 383,
        TUTORIAL_TRIGGER = 384,
        PET_DISMISS_START = 385,
        UPDATE_BINDINGS = 386,
        UPDATE_SHAPESHIFT_FORMS = 387,
        WHO_LIST_UPDATE = 388,
        UPDATE_LFG = 389,
        PETITION_SHOW = 390,
        PETITION_CLOSED = 391,
        EXECUTE_CHAT_LINE = 392,
        UPDATE_MACROS = 393,
        UPDATE_TICKET = 394,
        UPDATE_CHAT_WINDOWS = 395,
        CONFIRM_XP_LOSS = 396,
        CORPSE_IN_RANGE = 397,
        CORPSE_IN_INSTANCE = 398,
        CORPSE_OUT_OF_RANGE = 399,
        UPDATE_GM_STATUS = 400,
        PLAYER_UNGHOST = 401,
        BIND_ENCHANT = 402,
        REPLACE_ENCHANT = 403,
        TRADE_REPLACE_ENCHANT = 404,
        PLAYER_UPDATE_RESTING = 405,
        UPDATE_EXHAUSTION = 406,
        PLAYER_FLAGS_CHANGED = 407,
        GUILD_ROSTER_UPDATE = 408,
        GM_PLAYER_INFO = 409,
        MAIL_SHOW = 410,
        MAIL_CLOSED = 411,
        SEND_MAIL_MONEY_CHANGED = 412,
        SEND_MAIL_COD_CHANGED = 413,
        MAIL_SEND_INFO_UPDATE = 414,
        MAIL_SEND_SUCCESS = 415,
        MAIL_INBOX_UPDATE = 416,
        BATTLEFIELDS_SHOW = 417,
        BATTLEFIELDS_CLOSED = 418,
        UPDATE_BATTLEFIELD_STATUS = 419,
        UPDATE_BATTLEFIELD_SCORE = 420,
        AUCTION_HOUSE_SHOW = 421,
        AUCTION_HOUSE_CLOSED = 422,
        NEW_AUCTION_UPDATE = 423,
        AUCTION_ITEM_LIST_UPDATE = 424,
        AUCTION_OWNED_LIST_UPDATE = 425,
        AUCTION_BIDDER_LIST_UPDATE = 426,
        PET_UI_UPDATE = 427,
        PET_UI_CLOSE = 428,
        ADDON_LOADED = 429,
        VARIABLES_LOADED = 430,
        MACRO_ACTION_FORBIDDEN = 431,
        ADDON_ACTION_FORBIDDEN = 432,
        MEMORY_EXHAUSTED = 433,
        MEMORY_RECOVERED = 434,
        START_AUTOREPEAT_SPELL = 435,
        STOP_AUTOREPEAT_SPELL = 436,
        PET_STABLE_SHOW = 437,
        PET_STABLE_UPDATE = 438,
        PET_STABLE_UPDATE_PAPERDOLL = 439,
        PET_STABLE_CLOSED = 440,
        CHAT_MSG_COMBAT_SELF_HITS = 441,
        CHAT_MSG_COMBAT_SELF_MISSES = 442,
        CHAT_MSG_COMBAT_PET_HITS = 443,
        CHAT_MSG_COMBAT_PET_MISSES = 444,
        CHAT_MSG_COMBAT_PARTY_HITS = 445,
        CHAT_MSG_COMBAT_PARTY_MISSES = 446,
        CHAT_MSG_COMBAT_FRIENDLYPLAYER_HITS = 447,
        CHAT_MSG_COMBAT_FRIENDLYPLAYER_MISSES = 448,
        CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS = 449,
        CHAT_MSG_COMBAT_HOSTILEPLAYER_MISSES = 450,
        CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS = 451,
        CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES = 452,
        CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS = 453,
        CHAT_MSG_COMBAT_CREATURE_VS_PARTY_MISSES = 454,
        CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS = 455,
        CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_MISSES = 456,
        CHAT_MSG_COMBAT_FRIENDLY_DEATH = 457,
        CHAT_MSG_COMBAT_HOSTILE_DEATH = 458,
        CHAT_MSG_COMBAT_XP_GAIN = 459,
        CHAT_MSG_COMBAT_HONOR_GAIN = 460,
        CHAT_MSG_SPELL_SELF_DAMAGE = 461,
        CHAT_MSG_SPELL_SELF_BUFF = 462,
        CHAT_MSG_SPELL_PET_DAMAGE = 463,
        CHAT_MSG_SPELL_PET_BUFF = 464,
        CHAT_MSG_SPELL_PARTY_DAMAGE = 465,
        CHAT_MSG_SPELL_PARTY_BUFF = 466,
        CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE = 467,
        CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF = 468,
        CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE = 469,
        CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF = 470,
        CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE = 471,
        CHAT_MSG_SPELL_CREATURE_VS_SELF_BUFF = 472,
        CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE = 473,
        CHAT_MSG_SPELL_CREATURE_VS_PARTY_BUFF = 474,
        CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE = 475,
        CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF = 476,
        CHAT_MSG_SPELL_TRADESKILLS = 477,
        CHAT_MSG_SPELL_DAMAGESHIELDS_ON_SELF = 478,
        CHAT_MSG_SPELL_DAMAGESHIELDS_ON_OTHERS = 479,
        CHAT_MSG_SPELL_AURA_GONE_SELF = 480,
        CHAT_MSG_SPELL_AURA_GONE_PARTY = 481,
        CHAT_MSG_SPELL_AURA_GONE_OTHER = 482,
        CHAT_MSG_SPELL_ITEM_ENCHANTMENTS = 483,
        CHAT_MSG_SPELL_BREAK_AURA = 484,
        CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE = 485,
        CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS = 486,
        CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE = 487,
        CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS = 488,
        CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE = 489,
        CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS = 490,
        CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE = 491,
        CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS = 492,
        CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE = 493,
        CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS = 494,
        CHAT_MSG_SPELL_FAILED_LOCALPLAYER = 495,
        CHAT_MSG_BG_SYSTEM_NEUTRAL = 496,
        CHAT_MSG_BG_SYSTEM_ALLIANCE = 497,
        CHAT_MSG_BG_SYSTEM_HORDE = 498,
        RAID_ROSTER_UPDATE = 499,
        UPDATE_PENDING_MAIL = 500,
        UPDATE_INVENTORY_ALERTS = 501,
        UPDATE_TRADESKILL_RECAST = 502,
        OPEN_MASTER_LOOT_LIST = 503,
        UPDATE_MASTER_LOOT_LIST = 504,
        START_LOOT_ROLL = 505,
        CANCEL_LOOT_ROLL = 506,
        CONFIRM_LOOT_ROLL = 507,
        INSTANCE_BOOT_START = 508,
        INSTANCE_BOOT_STOP = 509,
        LEARNED_SPELL_IN_TAB = 510,
        DISPLAY_SIZE_CHANGED = 511,
        CONFIRM_TALENT_WIPE = 512,
        CONFIRM_BINDER = 513,
        MAIL_FAILED = 514,
        CLOSE_INBOX_ITEM = 515,
        CONFIRM_SUMMON = 516,
        BILLING_NAG_DIALOG = 517,
        IGR_BILLING_NAG_DIALOG = 518,
        MEETINGSTONE_CHANGED = 519,
        PLAYER_SKINNED = 520,
        TABARD_SAVE_PENDING = 521,
        UNIT_QUEST_LOG_CHANGED = 522,
        PLAYER_PVP_KILLS_CHANGED = 523,
        PLAYER_PVP_RANK_CHANGED = 524,
        INSPECT_HONOR_UPDATE = 525,
        UPDATE_WORLD_STATES = 526,
        AREA_SPIRIT_HEALER_IN_RANGE = 527,
        AREA_SPIRIT_HEALER_OUT_OF_RANGE = 528,
        CONFIRM_PET_UNLEARN = 529,
        PLAYTIME_CHANGED = 530,
        UPDATE_LFG_TYPES = 531,
        UPDATE_LFG_LIST = 532,
        CHAT_MSG_COMBAT_FACTION_CHANGE = 533,
        START_MINIGAME = 534,
        MINIGAME_UPDATE = 535,
        READY_CHECK = 536,
        RAID_TARGET_UPDATE = 537,
        GMSURVEY_DISPLAY = 538,
        UPDATE_INSTANCE_INFO = 539,
        SPELL_CAST_EVENT = 540,
        CHAT_MSG_RAID_BOSS_EMOTE = 541,
        COMBAT_TEXT_UPDATE = 542,
        LOTTERY_SHOW = 543,
        CHAT_MSG_FILTERED = 544,
        QUEST_WATCH_UPDATE = 545,
        CHAT_MSG_BATTLEGROUND = 546,
        CHAT_MSG_BATTLEGROUND_LEADER = 547,
        LOTTERY_ITEM_UPDATE = 548,
        SPELL_DAMAGE_EVENT_SELF = 549,
        SPELL_DAMAGE_EVENT_OTHER = 550,

        UNIT_CASTEVENT = 600,
        RAW_COMBATLOG = 601,
        CREATE_CHATBUBBLE = 602,

        OTHER_UI_EVENTS = 99999,
    };

    // Event tracking globals
    extern std::map<EVENT_ID, FunctionStats> gEventStats;
    extern std::map<std::string, FunctionStats> gAddonStats;
    extern std::map<std::string, FunctionStats> gAddonScriptEventStats;
    extern std::map<std::string, FunctionStats> gAddonOnUpdateStats;
    extern std::map<std::string, std::priority_queue<EventStats>> gAddonSlowEvents;
    extern int gLastEventCode;
    
    // Per-event code duration tracking
    extern std::map<int, FunctionStats> gEventCodeStats;
    extern std::map<int, std::chrono::high_resolution_clock::time_point> gEventCodeStartTimes;

    // Event initialization
    void initializeEventStats();

    // Get event name from event code
    std::string GetEventName(int eventCode);
}